﻿namespace WpfApp1.Acme.Template {
    /// <summary>
    /// 数据源操作接口
    /// </summary>
    /// <typeparam name="T">数据源对象</typeparam>
    public interface DataSourceOperation : BeanInitializing {

        /// <summary>
        /// 数据源连接
        /// </summary>
        /// <param name="dataSourceClass">数据源连接类</param>
        /// <returns></returns>
        bool connection(object dataSourceClass);

        /// <summary>
        /// 数据源数据操作方法，返回影响的行数
        /// </summary>
        /// <param name="sqlString">SQL语句</param>
        /// <param name="sqlParameters">SQL语句参数</param>
        /// <returns></returns>
        int ExecuteNonQuery(in string sqlString, params object[] sqlParameters);

        /// <summary>
        /// 数据库数据操作方法，返回修改的对象
        /// </summary>
        /// <param name="sqlString">SQL语句</param>
        /// <param name="sqlParameters">SQL语句参数</param>
        /// <returns></returns>
        object Executescalar(in string sqlString, params object[] sqlParameters);

        /// <summary>
        /// 数据源数据操作方法用于执行select语句
        /// </summary>
        /// <typeparam name="T">返回指定的实体映射类</typeparam>
        /// <param name="sqlString">SQL语句</param>
        /// <param name="objectMapper">映射实体映射类的映射类</param>
        /// <param name="sqlParameters">SQL语句参数</param>
        /// <returns></returns>
        T ExecuteReader<T>(in string sqlString, object objectMapper, params object[] sqlParameters);

        /// <summary>
        /// 数据源连接资源释放
        /// </summary>
        void close();
    }
}
